/*
 * @Author: zhanghongqiao 
 * @Date: 2020-10-21 14:55:39 
 * @Email: 991034150@qq.com 
 * @Description: 重置
 * @Last Modified by: zhanghongqiao
 * @Last Modified time: 2022-11-09 13:30:46
 */

<style lang="scss">
.tips_dialog {
  p {
    font-size: 18px; 
    color: var(--color-theme-s);
    text-align: center;
    margin-top: 34px;
  }
}
</style>

<template>
      <el-dialog 
      :modal-append-to-body="tobody"
      :close-on-click-modal="false"
      :show-close="false" 
     v-model="dialogVisible"
      width="408px"
      :before-close="handleClose">
      <p>{{text || '确定要删除选中项吗'}}</p>
      <template #footer class="dialog-footer">
        <el-button class="white_btn" @click="handleClose('')">取消</el-button>
        <el-button class="blue_btn"  @click="handleClose('ok')">{{'确定' || btnText}}</el-button> 
      </template>
    </el-dialog>
</template>


<script lang="ts">
import { defineComponent, ref, onMounted, toRefs, reactive } from 'vue'
 

export default defineComponent({
   props: {
    isShowTip: Boolean, 
    text: String,
    subText: String,
    isShow: Boolean,
    title: String,
    btnText: String,
    tobody: {
      type: Boolean,
      default: true
    }
  },
  emits: ['confirm', 'close'],
  model: {
    dialogVisible: Boolean
  },
  setup(props, { emit }) {
    // const dialogVisible = ref(false)
    const dataMap = reactive({
      dialogVisible: false
    })

    onMounted(() => {
      dataMap.dialogVisible = props.isShow 
    })
    const  handleClose = ((type: string) => {
        emit('close', false)
      if(type == 'ok') {
        emit('confirm')
      } 
      dataMap.dialogVisible  = false 
    })  
    
    return {
      ...toRefs(dataMap),
      handleClose
    }
  },
})
</script>
 